////#include<iostream>
////#include<string>
////#include<map>
////#include<set>
////#include<vector>
////#include<queue>
////using namespace std;
////
////vector<string> way;
////
////int main()
////{
////    map<string, queue<string>> m;
////    int n, x;
////    cin >> n >> x;
////    while (x--)
////    {
////        string user, web;
////        cin >> user >> web;
////        if (m[user].size() == 0)
////        {
////            way.push_back(user);
////        }
////        m[user].push(web);
////    }
////    for (auto& e : way)
////    {
////        cout << e << " ";
////        auto& k = m[e];
////        while (k.size())
////        {
////            cout << k.front() << " ";
////            k.pop();
////        }
////        cout << endl;
////    }
////    return 0;
////}
//
//#include<iostream>
//#include<stack>
//
//using namespace std;
//
//stack<int> be, mid, ret;
//
//int main()
//{
//    int n; cin >> n;
//    for (int i = n; i >= 1; i--)
//        be.push(i);
//    int a, b;
//    while (cin >> a >> b)
//    {
//        if (a == 1)
//        {
//            while (b--)
//            {
//                mid.push(be.top());
//                be.pop();
//            }
//        }
//        else
//        {
//            while (b--)
//            {
//                ret.push(mid.top());
//                mid.pop();
//            }
//        }
//    }
//    while (ret.size())
//    {
//        cout << ret.top() << endl;
//        ret.pop();
//    }
//    return 0;
//}